<script setup>
import { useGameStore, useUserStore } from '@/stores/index'
import { baseURL } from '@/utils/request'
import { ref } from 'vue'
const gameList = ref([])
const User = ref({})
const gameStore = useGameStore()
const userStore = useUserStore()
const getGameList = async (id) => {
  await gameStore.getGameListBySeller(id)
  gameList.value = gameStore.gameBusList
  console.log(gameList.value)
}
User.value = userStore.user

getGameList(User.value.id)
</script>
<template>
  <div class="done-publish">
    <h3>已发布游戏</h3>
    <ul v-if="gameList.length">
      <li v-for="item in gameList" :key="item.id">
        <el-card class="card" shadow="hover">
          <template #footer>
            <div class="title">{{ item.game_name }}</div>
            <div class="price">￥{{ item.price }}</div>
          </template>
          <img :src="baseURL + '/files/' + item.game_image" style="width: 100%" />
        </el-card>
      </li>
    </ul>
    <template v-else>
      <el-empty description="您还没有添加订单" />
    </template>
  </div>
</template>

<style scoped lang="scss">
h3 {
  color: #027efb;
}
.done-publish {
  height: -webkit-fill-available;
  ul {
    width: 100%;

    display: flex;

    flex-wrap: wrap;

    li:nth-child(4n + 1) {
      margin-left: 0;
    }
    li:nth-child(4n) {
      margin-right: 0;
    }
    li {
      margin: auto 7.5px;
    }

    .card {
      width: 180px;
      border: rgb(255, 255, 255) 1px solid;

      img {
        border-radius: 10px;
      }
    }

    .card:hover {
      border: rgb(64, 158, 255) 1px solid;
    }

    .title {
      margin-bottom: 5px;
      font-size: 18px;
      font-weight: 600;
      color: #333;
    }

    .price {
      font-size: 18px;
      font-weight: 600;
      color: #ff4d4f;
    }
  }
}
</style>
